<template>
  <div class="page-wrap">
    <el-card class="main-card">
      <div class="half-card cover-img">
        <div class="cover-text">
          <div class="cover-title">{{ coverTitle }}</div>
          <div class="cover-subtitle">{{ coverSubTitle }}</div>
        </div>
      </div>
      <div class="half-card input-box">
        <RouterView />
      </div>
    </el-card>
  </div>
</template>

<script setup>
import ASC from '/app_settings_core'
import { ref } from 'vue'

const coverImage = ref()
function initCoverImage() {
  // 先设置默认封面
  const defaultCoverUrl = new URL('/src/reserved/assets/images/portal/default-cover.jpg', import.meta.url)
  coverImage.value = `url(${defaultCoverUrl})`
  // 如果有配置封面则使用
  if (ASC.settings.portal.coverImageFileName) {
    const coverUrl = new URL('/', import.meta.url)
    coverUrl.pathname = `/src/custom/assets/images/portal/${ASC.settings.portal.coverImageFileName}`
    coverImage.value = `url(${coverUrl})`
  }
}
initCoverImage()

const coverTitle = ref(ASC.settings.portal.coverTitle)
const coverTitleSize = ref(ASC.settings.portal.coverTitleSize)
const coverTitleColor = ref(ASC.settings.portal.coverTitleColor)
const coverSubTitle = ref(ASC.settings.portal.coverSubTitle)
const coverSubTitleSize = ref(ASC.settings.portal.coverSubTitleSize)
const coverSubTitleColor = ref(ASC.settings.portal.coverSubTitleColor)
</script>

<style lang="scss" scoped>
.page-wrap {
  width: 100%;
  height: 100%;
  background-color: var(--el-bg-color-page);
  display: flex;
  align-items: center;
  justify-content: center;

  .main-card {
    $--main-card-width: 100rem;
    $--main-card-height: 60rem;
    width: $--main-card-width;
    height: $--main-card-height;
    border-radius: 0;

    :deep(.el-card__body) {
      width: 100%;
      height: 100%;
      padding: 0;
      display: flex;
      align-items: center;
      justify-content: space-around;
    }

    .half-card {
      width: 50%;
      height: 100%;
    }

    .cover-img {
      background-image: v-bind(coverImage);
      background-size: 100% 100%;
      display: flex;
      justify-content: center;

      .cover-text {
        width: 80%;
        height: 10rem;
        margin-top: 5rem;
        cursor: default;

        .cover-title {
          font-size: v-bind(coverTitleSize);
          color: v-bind(coverTitleColor);
        }

        .cover-subtitle {
          font-size: v-bind(coverSubTitleSize);
          color: v-bind(coverSubTitleColor);
        }
      }
    }

    .input-box {
      $--input-box-padding: 6rem;
      padding: $--input-box-padding;
      width: calc($--main-card-width / 2 - 2 * $--input-box-padding);
      height: calc($--main-card-height - 2 * $--input-box-padding);
    }
  }
}
</style>
